package com.hl.card.modular.pack.controller;

import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hl.card.common.util.ResponseData;
import com.hl.card.modular.pack.service.ScoreChangeService;

@RestController
@RequestMapping("/api/scoreChange")
public class ScoreChangeController {
	@Autowired
	private ScoreChangeService scoreChangeService;

	@RequestMapping("/getScoreInfo")
	public Object getScoreInfo(@RequestParam Map<String, String> map) {
		ResponseData resultData = new ResponseData();
		if (StringUtils.isEmpty(map.get("userId"))) {
			resultData.setData(null);
			resultData.setMsg("用户ID不能为空");
			resultData.setStatus("0");
			return resultData;
		}
		if (StringUtils.isEmpty(map.get("cardType"))) {
			resultData.setData(null);
			resultData.setMsg("卡种不能为空");
			resultData.setStatus("0");
			return resultData;
		}
		return scoreChangeService.getScoreInfo(map);
	}

	public Object change(@RequestParam Map<String, String> map) {
		ResponseData resultData = new ResponseData();
		if (StringUtils.isEmpty(map.get("userId"))) {
			resultData.setData(null);
			resultData.setMsg("用户ID不能为空");
			resultData.setStatus("0");
			return resultData;
		}
		if (StringUtils.isEmpty(map.get("cardType"))) {
			resultData.setData(null);
			resultData.setMsg("卡种不能为空");
			resultData.setStatus("0");
			return resultData;
		}
		return scoreChangeService.changeScore(map);
	}
}
